package com.emergency.evaluate.dao;


import com.emergency.evaluate.domain.Report;
import com.emergency.evaluate.domain.ReportNum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by Administrator on 2020/4/9.
 */
public interface ReportNumDao extends JpaRepository<ReportNum, String>, JpaSpecificationExecutor<ReportNum> {
    //根据ID查询报告
    @Query (value = "select r from ReportNum r where report.id=:reportId")
    List<ReportNum>   findAllByReport(@Param ( "reportId" ) Long reportId);

    //根据统计类型找出数据列表
    @Query (value = "select r from ReportNum r where r.type=:type")
    List<ReportNum>  findAllByType(@Param ( "type" ) int type);

    //根据评分报告ID删除报告
    @Modifying
    @Query(value = "delete from ReportNum  where report.id=:reportId")
    void deleteByReportId(@Param ( "reportId" ) Long reportId);


}
